package test.designmode.future;

/**
 * Created by linshuo on 2018/3/4.
 */
public class FutureClient {

    /**
     * 开线程去处理耗时任务,返回futureData供查询任务结果
     *
     * @param requestName
     * @return
     */
    public Data request(String requestName) {
        FutureData futureData = new FutureData();
        new Thread(() -> {
            RealData realData = new RealData();
            /* 耗时操作 */
            realData.doRequest(requestName);
            futureData.setRealData(realData);
        }).start();
        return futureData;
    }

}
